/*
 * 		Author : Xerxes
 * 		Program: 
 * 		Created On : 25.09.2011 20:10:56 BDT
 *      "I have not failed, I have just found 10000 ways that won't work.
 * 
*/


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define fo(i,st,ed) for(int i = st ; i < ed ; ++i )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define tp pair< int, pair<int,int> >
#define mmk( x, y , z ) mk( x, mk( y, z ) )

inline void wait( double seconds ){
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while( clock() < endtime ){
        ;
    }
}
set< int > nodes;
int x,y;
int cases=1;

vector< vector<int> >go;
inline void Read(){
	nodes.clear();
	go.assign(105, vector<int>() );
	go[x].pb(y);
	nodes.insert(x);
	nodes.insert(y);
	while( scanf("%d %d",&x,&y)==2 ){
		if( x==0 && y==0 )break;
		go[x].pb(y);
		nodes.insert(x);
		nodes.insert(y);
	}
}
int D[105];
const int inf = (int)1e5;
inline void bfs(int sx){
		fo(i,0,105){
			D[i]=inf;
		}
		
		queue< int >q;
		q.push( sx );
		D[sx]=0;
		
		while( q.empty()==false ){
			int father = q.front();
			q.pop();
			
			vector<int> cango = go[father];
			for(int i=0,j=SZ(cango);i<j;++i){
				int child = cango[i];
				int newCost = D[father]+1;
				if( newCost < D[child] ){
					D[child]=newCost;
					q.push( child );
				}
			}
		}
}

inline void Proc(){
	int sz  = SZ(nodes);
	int sum = 0;
	int niche = sz*(sz-1);
	foit(i,nodes){
		bfs( *i);
		//cout<<"From : "<<*i<<" :\n";
		foit(j,nodes){
			//cout<<D[ *j ]<<" ";
			sum+=D[ *j ];
		}
		//cout<<"\n";
	}
	double var = (double)sum/niche;
	printf("Case %d: average length between pages = %.3lf clicks\n",cases,var);
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("in","rt",stdin);
    #endif

	for( ; scanf("%d %d",&x,&y)==2 ;++cases){
		if( x==0 && y==0 )break;
		Read();
		Proc();
	}
return 0;
}


